/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package skelbkim;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

/**
 *
 * @author laimis
 * paslepti input laukeliai reikia skripto kuris parodutu visus pasleptus lauks
 *
 */
public class Olx extends SeleneseTestCase {

    public void setUp() throws Exception {
        setUp("http://kretinga.olx.lt/", "*firefox");
    }

    public void newNotation(String noticeText, String phone, String name, String noticeTitle, String email) throws Exception {
        selenium.open("/posting.php?src=8");
        if (isPageLoude()) {
            selenium.select("state", "label=Klaipeda");
            selenium.select("city", "label=Klaipeda");
            selenium.select("categoryParent", "label=Paslaugos");
            selenium.select("categoryChild", "label=Kitos paslaugos");
            selenium.waitForPageToLoad("10000");
            selenium.click("publish");
            selenium.type("email", email);
            selenium.type("title", noticeTitle);
            selenium.type("phone", phone);
            selenium.type("//*[@id=\"description\"]", noticeText);
            selenium.click("//*[@id='publish']");
        }
        selenium.stop();
    }

    private boolean isPageLoude() {
        boolean result = true;
        while (!selenium.isElementPresent("//*[@id='publish']")) {
            selenium.waitForPageToLoad("5000");
        }
        return result;
    }
}
